<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
    <title>亿人宝 - 账户设置</title>
    <meta content="" name="keywords"/>
    <meta content="" name="description"/>
    <link rel="stylesheet" th:href="@{/css/common.css}"/>
    <link rel="stylesheet" th:href="@{/css/user.css}" type="text/css"/>
    <link rel="stylesheet" th:href="@{/css/jquery.datetimepicker.css}" type="text/css"/>
    <script th:src="@{/script/jquery.min.js}" type="text/javascript"></script>
    <script th:src="@{/script/common.js}" type="text/javascript"></script>
    <script th:src="@{/script/user.js}" type="text/javascript"></script>
    <script th:src="@{/layui/layer/layer.js}" type="text/javascript"></script>
</head>
<body>
<div th:replace="common/public::head"></div>
<!--个人中心-->
<div class="wrapper wbgcolor">
    <div class="w1200 personal">
        <!--<div class="credit-ad"><img height="96" th:src="@{/images/clist1.jpg}" width="1200"></div>-->
        <div class="personal-left" id="personal-left">
            <ul>
                <li><span><a th:href="@{/per/index(option = 1)}"><i class="dot dot1"></i>账户总览</a></span></li>
                <li><span><a style="font-size:14px;text-align:center;width:115px;padding-right:35px;" th:href="@{/cap/cap_List}">资金记录</a></span></li>
                <li><span><a style="font-size:14px;text-align:center;width:115px;padding-right:35px;" th:href="@{/per/investlist(option = 1)}">投资记录</a></span>
                </li>
                <li><span><a style="font-size:14px;text-align:center;width:115px;padding-right:35px;" th:href="@{/per/prolist}">回款计划</a></span></li>
                <li><span><a th:href="@{/per/thirdparty}"><i class="dot dot02"></i>开通第三方</a> </span></li>
                <li><span><a th:href="@{/per/torecharge}"><i class="dot dot03"></i>充值</a></span></li>
                <li><span><a th:href="@{/per/towithdrawal}"><i class="dot dot04"></i>提现</a></span></li>
                <li style="position:relative;"><span> <a th:href="@{/per/toredenvelopes(state = 1)}"> <i class="dot dot06"></i> 我的红包 </a> </span></li>
                <li style="position:relative;"><span> <a th:href="@{/per/tomessages}"><i class="dot dot08"></i>系统信息 </a> </span></li>
                <li class="pleft-cur"><span><a th:href="@{/setUser/toView}"><i class="dot dot09"></i>账户设置</a></span></li>
            </ul>
        </div>
        <script type="text/javascript">
            //显示窗口方法定义
            function showSpan(op) {
                $("#updateMonbileForm\\:updateMonbileFormauthCode").val("");
                if (op == 'alert-updateEmail') {
                    var bool = $("#authenticationMobile").val();
                    if (bool == 'true') {
                        $("#alert-main").css("display", "none");
                        $("#alert-main2").css("display", "block");
                    }
                }
                $("body").append("<div id='mask'></div>");
                $("#mask").addClass("mask").css("display", "block");

                $("#" + op).css("display", "block");
            }

            //（关闭按钮）隐藏窗口方法定义
            function displaySpan(op) {
                clearInputValue();
                $("#mask").css("display", "none");
                $("#" + op).css("display", "none");
            }

            //（确认按钮操作成功后）隐藏窗口方法定义
            function displaySpan2() {
                $("#mask").css("display", "none");
                $("#alert-updateEmail").css("display", "none");

                $("body").append("<div id='mask'></div>");
                $("#mask").addClass("mask").css("display", "block");

                $("#alert-checkMobile").css("display", "block");
            }

            //隐藏窗口后清空输入框
            function clearInputValue() {
                //清空验证原手机验证码输入框
                $("#yzm").val("");
                //清空新手机输入框
                $("#xphone").val("");
                //清空新手机验证码输入框
                $("#xyzm").val("");
                //清空邮箱输入框
                $("#email").val("");
                //清空邮箱验证码输入框
                $("#emailyzm").val("");
                //清空原登录密码输入框
                $("#ymm").val("");
                //清空新登录密码输入框
                $("#xpwd1").val("");
                //清空确认新登录密码输入框
                $("#xpwd2").val("");
                //清空原支付密码输入框
                $("#zymm").val("");
                //清空新支付密码输入框
                $("#zxpwd1").val("");
                //清空确认新支付密码输入框
                $("#zxpwd2").val("");
            }

        </script>
        <style type="text/css">
            .txt235 {
                height: 38px;
                border: 1px solid #ccc;
            }

        </style>
        <input id="thi" th:value="${thi}" type="hidden"/>
        <div class="personal-main">
            <div class="personal-zhsz">
                <h3><i>账户设置</i></h3>
                <div class="personal-level">
                    <span class="wzd">您的账户完整度</span>
                    <i class="grzxbg level3" style="border: none; margin: 37px 0px 0px 20px; height: 17px; background-position: 0px -550px;"></i>
                    <span class="state">[中]</span>
                    <i class="markicon fl mt35" id="zhwzd"></i>
                    <span class="arrow-personal">请尽快完成账户安全设置，以确保您的账户安全</span>
                    <span class="grzxbg icon-personal"></span>
                </div>
                <ul>
                    <li>
                        <i class="grzxbg p-right"></i>
                        <span class="zhsz-span1">手机号</span>
                        <span class="zhsz-span2" th:text="${phone}">150****0139</span>
                        <span class="zhsz-span3">
                            <a href="javascript:void(0)" onclick="showSpan('alert-checkOldMobile')">更改</a>
                        </span>
                    </li>
                    <input id="authenticationMobile" type="hidden" value="false">
                    <li>
                        <i class="grzxbg p-danger" th:if="${thi == 0}"></i>
                        <i class="grzxbg p-right" th:if="${thi == 1}"></i>
                        <span class="zhsz-span1">身份认证</span>
                        <span class="zhsz-span2" th:if="${thi == 0}">未认证</span>
                        <span class="zhsz-span2" th:if="${thi == 1}">已认证</span>
                        <span class="zhsz-span3" th:if="${thi == 0}">
                            <a th:href="@{/per/thirdparty}">认证</a>
                        </span>
                        <span class="zhsz-span3" th:if="${thi == 1}">
                            已认证
                        </span>
                    </li>
                    <li>
                        <i class="grzxbg p-danger" th:if="${thi == 0}"></i>
                        <i class="grzxbg p-right" th:if="${thi == 1}"></i>
                        <span class="zhsz-span1">第三方支付</span>
                        <span class="zhsz-span2" th:if="${thi == 0}">未开通</span>
                        <span class="zhsz-span2" th:if="${thi == 1}">已开通</span>
                        <span class="zhsz-span3" th:if="${thi == 0}">
                            <a th:href="@{/per/thirdparty}">开通</a>
                        </span>
                        <span class="zhsz-span3" th:if="${thi == 1}">
                            已开通
                        </span>
                    </li>
                    <li>
                        <i class="grzxbg p-right"></i>
                        <span class="zhsz-span1">电子邮箱</span>
                        <span class="zhsz-span2" th:text="${email}">348****@qq.com</span>
                        <span class="zhsz-span3">
                            <a href="#" onclick="showSpan('alert-updateEmail')">更改</a>
                        </span>
                    </li>

                    <li>
                        <i class="grzxbg p-right"></i>
                        <span class="zhsz-span1">登录密码</span>
                        <span class="zhsz-span2"></span>
                        <span class="zhsz-span3">
                            <a href="javascript:void(0)" onclick="showSpan('alert-updatePass')">更改</a>
                        </span>
                    </li>
                    <li>
                        <i class="grzxbg p-danger" th:if="${thi == 0}"></i>
                        <i class="grzxbg p-right" th:if="${thi == 1}"></i>
                        <span class="zhsz-span1">支付密码</span>
                        <span class="zhsz-span2"></span>
                        <span class="zhsz-span3" th:if="${thi == 0}">
                            <a th:href="@{/per/thirdparty}">设置</a>
                        </span>
                        <span class="zhsz-span3" th:if="${thi == 1}">
                            <a href="javascript:void(0)" onclick="showSpan('alert-updatePaymentPassword')">更改</a>
                        </span>
                    </li>
                </ul>
            </div>
        </div>
        <input id="valiCodeError" name="valiCodeError" type="hidden">
        <div class="alert-450" id="alert-checkOldMobile" style="display:none;">
            <div class="alert-title">
                <h3>修改手机</h3>
                <span class="alert-close" onclick="displaySpan('alert-checkOldMobile')"></span>
            </div>
            <div class="alert-main">
                <form action="#" enctype="application/x-www-form-urlencoded" id="checkOldMobileForm" method="post" name="checkOldMobileForm"
                      onsubmit="return yzysj()">
                    <input name="checkOldMobileForm" type="hidden" value="checkOldMobileForm">
                    <ul>
                        <li>
                            <label class="txt-name">原手机号</label>
                            <label class="txt240" th:text="${phone}"> 150****0139</label>
                        </li>
                        <li>
                            <label class="txt-name">验证码</label>
                            <input class="txt110" id="yzm" maxlength="6" name="yzm" onkeyup="value=value.replace(/[^\d\.]/g,'')" placeholder="请输入验证码"
                                   type="text">
                            <span id="sendCode7">
                                <a class="btn-code" href="#" id="yyzmhq" onclick="jphoneverification()" style="background: green">
                                    免费获取校验码
                                </a>
                            </span>
                        </li>
                        <li>
                            <span class="txt-right" id="yphone" style="display:none;">
                                <i class="error-icon"></i>
                                <i class="error-tip" id="yphone2">验证码错误请重新输入</i>
                            </span>
                            <br>
                            <input class="btn-ok txt-right" id="jphoneyzsub" type="submit" value="确 认">
                        </li>
                    </ul>
                </form>
            </div>
        </div>
        <div class="alert-450" id="alert-updateMobile" style="display:none;">
            <div class="alert-title">
                <h3>修改手机</h3>
                <span class="alert-close" onclick="displaySpan('alert-updateMobile')"></span></div>
            <div class="alert-main">
                <form action="#" enctype="application/x-www-form-urlencoded" id="updateMonbileForm" method="post" name="updateMonbileForm"
                      onsubmit="return yzxsj()">
                    <input name="updateMonbileForm" type="hidden" value="updateMonbileForm">
                    <ul>
                        <li style="width: 450px">
                            <label class="txt-name" style="width: 65px;">新手机号</label>
                            <input autocomplete="off" class="txt240" id="xphone" maxlength="11" name="xphone" onkeyup="value=value.replace(/[^\d\.]/g,'')"
                                   placeholder="请输入手机号" type="text">
                            <span class="txt-right" id="xphone2" style="display:none; margin-top: -25px; margin-left: 330px;">
                                <i class="error-icon" id="is"></i>
                                <i class="error-tip" id="xphone3">手机号不正确</i>
                            </span>
                        </li>
                        <li style="margin-top: 5px;">
                            <label class="txt-name" style="width: 65px;">验证码</label>
                            <input class="txt110" id="xyzm" maxlength="6" name="xyzm" onkeyup="value=value.replace(/[^\d\.]/g,'')" placeholder="请输入验证码"
                                   type="text">
                            <span id="sendCode1">
                                <a class="btn-code" href="#" id="xyzmhq" onclick="xphoneverification()" style="background: green">
                                    免费获取校验码
                                </a>
                            </span>
                        </li>
                        <li style="width: 450px;">
                            <span class="txt-right" id="xphonets" style="display:none;margin-top: -25px; margin-left: 327px;">
                                <i class="error-icon"></i>
                                <i class="error-tip" id="xsjwz">验证码错误请重新输入</i>
                            </span>
                            <input class="btn-ok txt-right" id="xsjsub" style="width: 235px;margin-left: 78px;" type="submit" value="确 认">
                        </li>
                    </ul>
                </form>
            </div>
        </div>

        <input id="valiChangeEamilError" name="valiChangeEamilError" type="hidden">
        <div class="alert-450" id="alert-updateEmail" style="display:none;">
            <div class="alert-title">
                <h3>修改邮箱</h3>
                <span class="alert-close" onclick="displaySpan('alert-updateEmail')"></span>
            </div>
            <div class="alert-main" id="alert-main">
                <form action="#" enctype="application/x-www-form-urlencoded" id="changeEmailForm" method="post" name="changeEmailForm" onsubmit="return yxyz()">
                    <input class="phone" name="phone" th:value="${session.user.phone}" type="hidden">
                    <ul>
                        <li style="width: 450px;">
                            <label class="txt-name" style="width: 90px;">请输入新邮箱</label>
                            <input class="txt235" id="email" name="email" placeholder="请输入邮箱" type="text">
                            <span class="txt-right" id="xemail" style="display:none;margin-top: -25px;margin-left: 345px;">
                                <i class="error-icon" id="em"></i>
                                <i class="error-tip" id="xemailwz">邮箱格式不正确</i>
                            </span>
                        </li>
                        <li style="margin-top: 5px;">
                            <label class="txt-name" style="width: 90px;">手机验证码</label>
                            <input class="txt110" id="emailyzm" maxlength="6" onkeyup="value=value.replace(/[^\d\.]/g,'')" placeholder="请输入手机验证码" type="text">
                            <span id="sendCode2">
                                <a class="btn-code" href="#" id="emailyzmhq" onclick="emailyzmhq()" style="width: 112px;background: green">免费获取校验码</a>
                            </span>
                        </li>
                        <li style="width: 450px;">
                            <span class="txt-right" id="emailts" style="display:none;margin-top: -25px; margin-left: 342px;">
                                <i class="error-icon"></i>
                                <i class="error-tip" id="emailwz">验证码错误</i>
                            </span>
                            <input class="btn-ok txt-right" id="emailqr" style="width: 225px;margin-left: 103px;" type="submit" value="确　认">
                        </li>
                    </ul>
                </form>
            </div>
        </div>
        <div class="alert-450" id="alert-updatePass" style="display: none;">
            <div class="alert-title">
                <h3>修改登录密码</h3>
                <span class="alert-close" onclick="displaySpan('alert-updatePass')"></span></div>
            <div class="alert-main">
                <form action="#" enctype="application/x-www-form-urlencoded" id="updatePassForm" method="post" name="updatePassForm">
                    <ul>
                        <li>
                            <label class="txt-name">请输入原密码</label>
                            <input class="txt235" id="ymm" maxlength="20" name="ypwd" placeholder="请输入原登录密码" type="password">
                            <span class="txt-right" id="ymmts" style="display:none;margin-top: -25px;margin-left: 375px;">
                                <i class="error-icon"></i>
                            </span>
                        </li>
                        <li style="margin-top: 5px;">
                            <label class="txt-name">请输入新密码</label>
                            <input class="txt235" id="xpwd1" maxlength="20" name="xpwd1" placeholder="请输入新登录密码" type="password">
                            <span class="txt-right" id="xmmts1" style="display:none;margin-top: -25px;margin-left: 375px;">
                                <i class="error-icon"></i>
                            </span>
                        </li>
                        <li style="margin-top: 5px;">
                            <label class="txt-name">请确认新密码</label>
                            <input class="txt235" id="xpwd2" maxlength="20" name="xpwd2" placeholder="请再次输入新登录密码" type="password">
                            <span class="txt-right" id="xmmts2" style="display:none;margin-top: -25px;margin-left: 375px;">
                                <i class="error-icon"></i>
                            </span>
                        </li>
                        <li>
                            <input class="btn-ok btn-235 txt-right" onclick="xgmm()" style="width: 225px;" type="button" value="确 认">
                        </li>
                    </ul>
                </form>
            </div>
        </div>
        <div class="alert-450" id="alert-updatePaymentPassword" style="display: none;">
            <div class="alert-title">
                <h3>修改支付密码</h3>
                <span class="alert-close" onclick="displaySpan('alert-updatePaymentPassword')"></span></div>
            <div class="alert-main">
                <form action="#" enctype="application/x-www-form-urlencoded" method="post" name="updatePassForm" onsubmit="return zxgmm()">
                    <ul>
                        <li>
                            <label class="txt-name">请输入原密码</label>
                            <input class="txt235" id="zymm" maxlength="6" name="zypwd" onkeyup="value=value.replace(/[^\d\.]/g,'')" placeholder="请输入原支付密码"
                                   type="password">
                            <span class="txt-right" id="zymmts" style="display:none;margin-top: -25px;margin-left: 375px;">
                                <i class="error-icon"></i>
                            </span>
                        </li>
                        <li style="margin-top: 5px;">
                            <label class="txt-name">请输入新密码</label>
                            <input class="txt235" id="zxpwd1" maxlength="6" name="zxpwd1" onkeyup="value=value.replace(/[^\d\.]/g,'')" placeholder="请输入新支付密码"
                                   type="password">
                            <span class="txt-right" id="zxmmts1" style="display:none;margin-top: -25px;margin-left: 375px;">
                                <i class="error-icon"></i>
                            </span>
                        </li>
                        <li style="margin-top: 5px;">
                            <label class="txt-name">请确认新密码</label>
                            <input class="txt235" id="zxpwd2" maxlength="6" name="zxpwd2" onkeyup="value=value.replace(/[^\d\.]/g,'')" placeholder="请再次输入新支付密码"
                                   type="password">
                            <span class="txt-right" id="zxmmts2" style="display:none;margin-top: -25px;margin-left: 375px;">
                                <i class="error-icon"></i>
                            </span>
                        </li>
                        <li>
                            <input class="btn-ok btn-235 txt-right" style="width: 225px;" type="submit" value="确 认">
                        </li>
                    </ul>
                </form>
            </div>
        </div>
        <div class="clear"></div>
    </div>
</div>
<!--网站底部-->
<div class="ft" id="footer">
    <div th:replace="common/public::footer"></div>
</div>
<script type="text/javascript">
    //显示账户设置进度条
    var thi = $("#thi").val().trim();
    if (thi == 0) {
        $("i[class='grzxbg level3']").css(
            {
                backgroundPosition: "0px -550px",
                border: "none",
                margin: "37px 0px 0px 20px",
                height: "17px"
            });
    } else if (thi == 1) {
        $("i[class='grzxbg level3']").css(
            {
                backgroundPosition: "0px -570px",
                border: "none",
                margin: "37px 0px 0px 20px",
                height: "17px"
            });
        $(".state").html("[高]");
        $(".arrow-personal").html("您已完成全部的安全设置，您的账户很安全！")
    }

    //--------------------------------------------------------------------------------------------------------------------

    var i = 60;
    //验证原手机号验证码倒数方法定义
    let timer;  //实例一个属性，装setInterval定时器。
    function ytimes() {
        //setTimeout(function () {
        if (i == 0) {
            $('#yyzmhq').attr("disabled", false).css("pointer-events", "auto");
            $("#yyzmhq").html("重新获取");
            $('#yyzmhq').css("background", "#EA524A");
            i = 60;
            clearInterval(timer);  //清空定时器
        } else {
            $('#yyzmhq').attr("disabled", true).css("pointer-events", "none");  //禁用a标签
            $("#yyzmhq").html("重新发送(" + i + ")");
            $('#yyzmhq').css("background", "green");
            i = i - 1;
            //ytimes();
        }
        //}, 1000);
    }

    //生成原手机短信验证码
    $('#jphoneyzsub').attr("disabled", true);  //点击获取验证码前禁用确认按钮
    $('#jphoneyzsub').css("background", "lightgray");
    $('#yzm').attr("disabled", true);  //点击获取验证码前禁用输入框（原手机号验证码输入框）
    function jphoneverification() {
        //发送请求生成验证码
        let zzz = layer.load();  //实例等待防触层
        $.post("[[@{/setUser/smsverification}]]", {}, function (data) {
            layer.close(zzz);  //关闭等待防触层
            layer.msg('手机验证码已发送到您绑定的手机，请注意查收！', {
                icon: 6
            });
            // alert('手机验证码已发送到您绑定的手机，请注意查收！');
        }, 'json');
        //执行倒数时间效果
        //ytimes();
        //把setInterval定时器装进timer中
        timer = setInterval(ytimes, 1000);
        //解除禁用确认按钮
        $('#jphoneyzsub').attr("disabled", false);
        $('#jphoneyzsub').css("background", "#0caffe");
        //解除禁用输入框（原手机号验证码输入框）
        $('#yzm').attr("disabled", false);
    }

    //验证原手机验证码是否正确
    function yzysj() {
        var yzm = $("#yzm").val().trim();  //获取确认是原手机输入框的验证码
        if (yzm == "" | yzm == null) {
            $("#yphone").css("display", "initial");
            $("#yphone2").html("请输入验证码！");
            setTimeout("$('#yphone').css('display', 'none')", 3000);
        } else {
            let zzz = layer.load();
            $.ajax({
                url: '[[@{/setUser/verification}]]',
                type: 'post',
                async: false,
                data: {yzm: yzm},
                dataType: 'json',
                success: function (data) {
                    layer.close(zzz);
                    if (data == 0) {
                        $("#yphone").css("display", "initial");
                        $("#yphone2").html("验证码错误！");
                        setTimeout("$('#yphone').css('display', 'none')", 3000);
                    } else if (data == 1) {
                        displaySpan('alert-checkOldMobile');  //关闭验证原手机号窗口
                        i = 60;
                        clearInterval(timer);  //清空定时器
                        showSpan('alert-updateMobile');  //打开修改手机号窗口
                    }
                }
            });
        }
        return false;
    }

    //-----------------------------------------------------------------------------------------------------------------

    //验证新手机号码格式是否正确
    var xsj = false;
    var xyzms = false;
    $("#xyzm").attr("disabled", true);  //禁用新手机验证码输入框
    $("#xyzmhq").attr("disabled", true).css("pointer-events", "none");  //禁用获取（新手机号）验证码“按钮”
    $('#xyzmhq').css("background", "lightgray");
    $("#xsjsub").attr("disabled", true);  //禁用新手机号确认按钮
    $('#xsjsub').css("background", "lightgray");
    $("#xphone").blur(window.oninput = function () {
        var xphone = $("#xphone").val().trim();
        if (xphone == "" | xphone == null) {
            $("#xphone2").css("display", "initial");
            $("#xphone3").html("请输入手机号！");
            $("#is").css("display", "initial");
            $("#xphone3").css("color", "#ff6565");
            $("#xyzm").attr("disabled", true);  //禁用新手机验证码输入框
            $("#xyzmhq").attr("disabled", true).css("pointer-events", "none");  //禁用获取（新手机号）验证码“按钮”
            $('#xyzmhq').css("background", "lightgray");
            $("#xsjsub").attr("disabled", true);  //禁用新手机号确认按钮
            $('#xsjsub').css("background", "lightgray");
            xsj = false;
        } else if (!(/^(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[8-9])[0-9]{8}$/).test(xphone)) {
            $("#xphone2").css("display", "initial");
            $("#xphone3").html("格式不正确！");
            $("#is").css("display", "initial");
            $("#xphone3").css("color", "#ff6565");
            $("#xyzm").attr("disabled", true);  //禁用新手机验证码输入框
            $("#xyzmhq").attr("disabled", true).css("pointer-events", "none");  //禁用获取（新手机号）验证码“按钮”
            $('#xyzmhq').css("background", "lightgray");
            $("#xsjsub").attr("disabled", true);  //禁用新手机号确认按钮
            $('#xsjsub').css("background", "lightgray");
            xsj = false;
        } else {
            let zzz = layer.load();
            $.ajax({
                url: '[[@{/setUser/selphone}]]',
                type: 'post',
                async: false,
                data: {phone: xphone},
                dataType: 'json',
                success: function (data) {
                    layer.close(zzz);
                    if (data == 1) {
                        $("#xphone2").css("display", "initial");
                        $("#xphone3").html("手机号已绑定！");
                        $("#is").css("display", "initial");
                        $("#xphone3").css("color", "#ff6565");
                        $("#xyzm").attr("disabled", true);  //禁用新手机验证码输入框
                        $("#xyzmhq").attr("disabled", true).css("pointer-events", "none");  //禁用获取（新手机号）验证码“按钮”
                        $('#xyzmhq').css("background", "lightgray");
                        $("#xsjsub").attr("disabled", true);  //禁用新手机号确认按钮
                        $('#xsjsub').css("background", "lightgray");
                        xsj = false;
                    } else if (data == 0) {
                        $("#xphone2").css("display", "initial");
                        $("#xphone3").html("手机号可用！");
                        $("#is").css("display", "none");
                        $("#xphone3").css("color", "green");
                        $("#xyzmhq").attr("disabled", false).css("pointer-events", "auto");  //解除禁用获取（新手机号）验证码“按钮”
                        $('#xyzmhq').css("background", "green");
                        xsj = true;
                    }
                }
            });
        }
    });
    //验证新手机号验证码倒数方法定义
    let timer2;  //实例一个属性来装setInterval定时器
    function xtimes() {
        if (i == 0) {
            $('#xyzmhq').attr("disabled", false).css("pointer-events", "auto");
            $("#xyzmhq").html("重新获取");
            $('#xyzmhq').css("background", "#EA524A");
            i = 60;
            clearInterval(timer2);  //清空定时器
        } else {
            $('#xyzmhq').attr("disabled", true).css("pointer-events", "none");  //禁用a标签
            $("#xyzmhq").html("重新发送(" + i + ")");
            $('#xyzmhq').css("background", "green");
            i = i - 1;
        }
    }

    //新手机号生成验证码
    function xphoneverification() {
        var xphone = $("#xphone").val().trim();
        if (xsj) {
            let zzz = layer.load();
            $.ajax({
                url: '[[@{/setUser/smsverification}]]',
                type: 'post',
                async: false,
                data: {phone: xphone},
                dataType: 'json',
                success: function (data) {
                    layer.close(zzz);
                    layer.msg('手机验证码已发送到您新的手机号，请注意查收！', {
                        icon: 6
                    });
                }
            });
            //setInterval定时器装入timer2属性中
            timer2 = setInterval(xtimes, 1000);
            $("#xyzm").attr("disabled", false);  //解除禁用新手机验证码输入框
            $("#xsjsub").attr("disabled", false);  //解除禁用新手机号确认按钮
            $('#xsjsub').css("background", "#0caffe");
            xyzms = true;
        } else {
            xyzms = false;
        }
    }

    //新手机号确认按钮（验证验证码是否正确）
    function yzxsj() {
        if (xyzms) {
            var xyzm = $("#xyzm").val().trim();
            var xphone = $("#xphone").val().trim();
            if (xyzm == "" | xyzm == null) {
                $("#xphonets").css("display", "initial");
                $("#xsjwz").html("验证码为空！");
                setTimeout("$('#xphonets').css('display', 'none')", 3000);
            } else {
                let zzz = layer.load();
                $.ajax({
                    url: '[[@{/setUser/verification}]]',
                    type: 'post',
                    async: false,
                    data: {yzm: xyzm},
                    dataType: 'json',
                    success: function (data) {
                        if (data == 0) {
                            layer.close(zzz);
                            $("#xphonets").css("display", "initial");
                            $("#xsjwz").html("验证码错误");
                            setTimeout("$('#xphonets').css('display', 'none')", 3000);
                        } else if (data == 1) {
                            $.ajax({
                                url: '[[@{/setUser/updphone}]]',
                                type: 'post',
                                async: false,
                                data: {phone: xphone},
                                dataType: 'json',
                                success: function (data2) {
                                    layer.close(zzz);
                                    if (data2 == 1) {
                                        layer.msg('修改成功', {time: 1000, icon: 1}, function () {
                                            //刷新页面
                                            location.reload();
                                        });
                                    } else if (data2 == 0) {
                                        layer.msg('系统错误，请联系管理员！', {icon: 3}, function () {
                                            location.reload();
                                        });
                                    }
                                }
                            });
                        }
                    }
                });
            }
        }
        return false;
    }

    //------------------------------------------------------------------------------------------------------------------

    //验证邮箱格式是否正确
    var emailbln = false;
    $("#emailyzm").attr("disabled", true);  //禁用新邮箱验证码输入框
    $("#emailyzmhq").attr("disabled", true).css("pointer-events", "none");  //禁用获取（新邮箱）验证码“按钮”
    $('#emailyzmhq').css("background", "lightgray");
    $("#emailqr").attr("disabled", true);  //禁用新邮箱确认按钮
    $('#emailqr').css("background", "lightgray");
    $("#email").blur(window.oninput = function () {
        var email = $("#email").val().trim();
        var atpos = email.indexOf("@");
        var dotpos = email.lastIndexOf(".");
        if (email == "" | email == null) {
            $("#xemail").css("display", "initial");
            $("#xemailwz").html("邮箱不能为空");
            $("#xemailwz").css("color", "#ff6565");
            $("#emailyzm").attr("disabled", true);  //禁用新邮箱验证码输入框
            $("#emailyzmhq").attr("disabled", true).css("pointer-events", "none");  //禁用获取（新邮箱）验证码“按钮”
            $('#emailyzmhq').css("background", "lightgray");
            $("#emailqr").attr("disabled", true);  //禁用新邮箱确认按钮
            $('#emailqr').css("background", "lightgray");
            emailbln = false;
            $("#em").css("display", "initial");
        } else if (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= email.length) {
            $("#xemail").css("display", "initial");
            $("#xemailwz").html("此邮箱无效");
            $("#xemailwz").css("color", "#ff6565");
            $("#emailyzm").attr("disabled", true);  //禁用新邮箱验证码输入框
            $("#emailyzmhq").attr("disabled", true).css("pointer-events", "none");  //禁用获取（新邮箱）验证码“按钮”
            $('#emailyzmhq').css("background", "lightgray");
            $("#emailqr").attr("disabled", true);  //禁用新邮箱确认按钮
            $('#emailqr').css("background", "lightgray");
            $("#em").css("display", "initial");
            emailbln = false
        } else {
            let zzz = layer.load();
            $.ajax({
                url: '[[@{/setUser/selemail}]]',
                type: 'post',
                async: false,
                data: {email: email},
                dataType: 'json',
                success: function (data3) {
                    layer.close(zzz);
                    if (data3 == 1) {
                        $("#xemail").css("display", "initial");
                        $("#xemailwz").html("此邮箱已注册");
                        $("#xemailwz").css("color", "#ff6565");
                        $("#emailyzm").attr("disabled", true);  //禁用新邮箱验证码输入框
                        $("#emailyzmhq").attr("disabled", true).css("pointer-events", "none");  //禁用获取（新邮箱）验证码“按钮”
                        $('#emailyzmhq').css("background", "lightgray");
                        $("#emailqr").attr("disabled", true);  //禁用新邮箱确认按钮
                        $('#emailqr').css("background", "lightgray");
                        $("#em").css("display", "initial");
                        emailbln = false
                    } else if (data3 == 0) {
                        $("#xemail").css("display", "initial");
                        $("#xemailwz").html("邮箱可用");
                        $("#xemailwz").css("color", "green");
                        $("#em").css("display", "none");
                        $("#emailyzmhq").attr("disabled", false).css("pointer-events", "auto");
                        $('#emailyzmhq').css("background", "green");
                        emailbln = true;
                    }
                }
            })
        }
    });
    //验证新手机号验证码倒数方法定义
    let timer3;  //实例一个属性来装setInterval定时器
    function ztimes() {
        if (i == 0) {
            $('#xyzmhq').attr("disabled", false).css("pointer-events", "auto");
            $("#xyzmhq").html("重新获取");
            $('#xyzmhq').css("background", "#EA524A");
            i = 60;
            clearInterval(timer3);  //清空定时器
        } else {
            $('#xyzmhq').attr("disabled", true).css("pointer-events", "none");  //禁用a标签
            $("#xyzmhq").html("重新发送(" + i + ")");
            $('#xyzmhq').css("background", "green");
            i = i - 1;
        }
    }

    //修改邮箱获取验证码点击事件
    function emailyzmhq() {
        var phone = $(".phone").val().trim();
        if (emailbln) {
            let zzz = layer.load();
            $.ajax({
                url: '[[@{/setUser/smsverification}]]',
                type: 'post',
                async: false,
                data: {phone: phone},
                dataType: 'json',
                success: function (data) {
                    layer.close(zzz);
                    layer.msg('手机验证码已发送到您绑定的手机号，请注意查收！', {
                        icon: 6
                    });
                }
            });
            //setInterval定时器装入timer2属性中
            timer3 = setInterval(ztimes, 1000);
            $("#emailyzm").attr("disabled", false);  //解除禁用新邮箱验证码输入框
            $("#emailqr").attr("disabled", false);  //禁用新邮箱确认按钮
            $('#emailqr').css("background", "#0caffe");
        }
    }

    //修改邮箱确认按钮验证短信验证码是否正确
    function yxyz() {
        var emailyzm = $("#emailyzm").val().trim();
        var email = $("#email").val().trim();
        if (emailyzm == "" | emailyzm == null) {
            $("#emailts").css("display", "initial");
            $("#emailwz").html("验证码不能为空");
            setTimeout('$("#emailts").css("display", "none")', 3000);
        } else {
            let zzz = layer.load();
            $.ajax({
                url: '[[@{/setUser/verification}]]',
                type: 'post',
                async: false,
                data: {yzm: emailyzm},
                dataType: 'json',
                success: function (data) {
                    if (data == 0) {
                        layer.close(zzz);
                        $("#emailts").css("display", "initial");
                        $("#emailwz").html("验证码错误");
                        setTimeout('$("#emailts").css("display", "none")', 3000);
                    } else if (data == 1) {
                        $.ajax({
                            url: '[[@{/setUser/updemail}]]',
                            type: 'post',
                            async: false,
                            data: {email: email},
                            dataType: 'json',
                            success: function (data2) {
                                layer.close(zzz);
                                if (data2 == 0) {
                                    layer.msg('系统错误，请联系管理员！', {icon: 3}, function () {
                                        //刷新页面
                                        location.reload();
                                    });
                                } else if (data2 == 1) {
                                    layer.msg('修改成功', {time: 1000}, {icon: 1}, function () {
                                        //刷新页面
                                        location.reload();
                                    });
                                }
                            }
                        })
                    }
                }
            });
        }
        return false;
    }

    //--------------------------------------------------------------------------------------------------------------------

    //修改登录密码
    var ymmbln = false;
    var xmmbln1 = false;
    var xmmbln2 = false;
    //原密码输入框失去焦点事件
    $("#ymm").blur(function () {
        var ymm = $("#ymm").val().trim();
        if (ymm == "" | ymm == null) {
            layer.msg('原密码不能为空', {
                icon: 5
            });
            $("#ymmts").css("display", "initial");
            ymmbln = false;
        } else if (!(/^[a-zA-Z][a-zA-Z0-9]*$/).test(ymm)) {
            layer.msg('密码必须以字母开头，且只能由字母和数字组成', {
                icon: 5
            });
            $("#ymmts").css("display", "initial");
            ymmbln = false;
        } else if (ymm.length < 6 | ymm.length > 15) {
            layer.msg('密码必须为6-14为字符', {
                icon: 5
            });
            $("#ymmts").css("display", "initial");
            ymmbln = false;
        } else {
            $("#ymmts").css("display", "none");
            ymmbln = true;
        }
    });
    //新密码输入框
    $("#xpwd1").blur(function () {
        var xpwd1 = $("#xpwd1").val().trim();
        if (xpwd1 == "" | xpwd1 == null) {
            layer.msg('新密码不能为空', {
                icon: 5
            });
            $("#xmmts1").css("display", "initial");
            xmmbln1 = false;
        } else if (!(/^[a-zA-Z][a-zA-Z0-9]*$/).test(xpwd1)) {
            layer.msg('新密码必须以字母开头，且只能由字母和数字组成', {
                icon: 5
            });
            $("#xmmts1").css("display", "initial");
            xmmbln1 = false;
        } else if (xpwd1.length < 6 | xpwd1.length > 15) {
            layer.msg('新密码必须为6-14为字符', {
                icon: 5
            });
            $("#xmmts1").css("display", "initial");
            xmmbln1 = false;
        } else {
            $("#xmmts1").css("display", "none");
            xmmbln1 = true;
        }
    });
    //确认密码输入框
    $("#xpwd2").blur(function () {
        var xpwd2 = $("#xpwd2").val().trim();
        if (xpwd2 == "" | xpwd2 == null) {
            layer.msg('确认密码不能为空', {
                icon: 5
            });
            $("#xmmts2").css("display", "initial");
            xmmbln2 = false;
        } else if (!(/^[a-zA-Z][a-zA-Z0-9]*$/).test(xpwd2)) {
            layer.msg('确认密码必须以字母开头，且只能由字母和数字组成', {
                icon: 5
            });
            $("#xmmts2").css("display", "initial");
            xmmbln2 = false;
        } else if (xpwd2.length < 6 | xpwd2.length > 15) {
            layer.msg('确认密码必须为6-14为字符', {
                icon: 5
            });
            $("#xmmts2").css("display", "initial");
            xmmbln2 = false;
        } else {
            $("#xmmts2").css("display", "none");
            xmmbln2 = true;
        }
    });

    //修改密码确认按钮
    function xgmm() {
        if (ymmbln & xmmbln1 & xmmbln2) {  //验证都成功时
            var ymm = $("#ymm").val().trim();
            var xpwd1 = $("#xpwd1").val().trim();
            var xpwd2 = $("#xpwd2").val().trim();
            if (xpwd1 != xpwd2) {
                layer.msg('新密码和确认密码不一致', {
                    icon: 5
                });
            } else if (ymm == xpwd1 | ymm == xpwd2) {
                layer.msg('原密码和新密码一致', {
                    icon: 5
                });
            } else if (xpwd1 == xpwd2 | ymm != xpwd1) {
                //验证原密码是否正确
                let zzz = layer.load();
                $.ajax({
                    url: '[[@{/setUser/selpwd}]]',
                    type: 'post',
                    async: true,
                    data: {pwd: ymm},
                    dataType: 'json',
                    success: function (data) {
                        if (data == 0) {
                            layer.close(zzz);
                            layer.msg('原密码错误', {
                                icon: 2
                            });
                        } else if (data == 1) {  //验证成功后修改密码
                            $.ajax({
                                url: '[[@{/setUser/updpwd}]]',
                                type: 'post',
                                async: true,
                                data: {xmm: xpwd1},
                                dataType: 'json',
                                success: function (data2) {
                                    layer.close(zzz);
                                    if (data2 == 0) {
                                        layer.msg('系统错误，请联系管理员！', {icon: 5}, function () {
                                            location.reload();
                                        });
                                    } else if (data2 == 1) {
                                        layer.msg('修改成功！请重新登录！', {time: 1000, icon: 1}, function () {
                                            location.href = "[[@{/login}]]"
                                        });
                                    }
                                }
                            });
                        }
                    }
                });
            }
        } else {
            layer.msg('请完善信息！', {
                icon: 5
            });
        }
        if (!ymmbln) {
            $("#ymmts").css("display", "initial");
        }
        if (!xmmbln1) {
            $("#xmmts1").css("display", "initial");
        }
        if (!xmmbln2) {
            $("#xmmts2").css("display", "initial");
        }
    }

    //--------------------------------------------------------------------------------------------------------------------

    //修改支付密码
    var zymmbln = false;
    var zxmmbln1 = false;
    var zxmmbln2 = false;
    //原密码输入框失去焦点事件
    $("#zymm").blur(function () {
        var zymm = $("#zymm").val().trim();
        if (zymm == "" | zymm == null) {
            layer.msg('原密码不能为空', {
                icon: 5
            });
            $("#zymmts").css("display", "initial");
            zymmbln = false;
        } else if (zymm.length != 6) {
            layer.msg('原密码必须为6位数字', {
                icon: 5
            });
            $("#zymmts").css("display", "initial");
            zymmbln = false;
        } else {
            $("#zymmts").css("display", "none");
            zymmbln = true;
        }
    });
    //新密码输入框
    $("#zxpwd1").blur(function () {
        var zxpwd1 = $("#zxpwd1").val().trim();
        if (zxpwd1 == "" | zxpwd1 == null) {
            layer.msg('新密码不能为空', {
                icon: 5
            });
            $("#zxmmts1").css("display", "initial");
            zxmmbln1 = false;
        } else if (zxpwd1.length != 6) {
            layer.msg('新密码必须为6位数字', {
                icon: 5
            });
            $("#zxmmts1").css("display", "initial");
            zxmmbln1 = false;
        } else {
            $("#zxmmts1").css("display", "none");
            zxmmbln1 = true;
        }
    });
    //确认密码输入框
    $("#zxpwd2").blur(function () {
        var zxpwd2 = $("#zxpwd2").val().trim();
        if (zxpwd2 == "" | zxpwd2 == null) {
            layer.msg('确认密码不能为空', {
                icon: 5
            });
            $("#zxmmts2").css("display", "initial");
            zxmmbln2 = false;
        } else if (zxpwd2.length != 6) {
            layer.msg('确认密码必须为6位数字', {
                icon: 5
            });
            $("#zxmmts2").css("display", "initial");
            zxmmbln2 = false;
        } else {
            $("#zxmmts2").css("display", "none");
            zxmmbln2 = true;
        }
    });

    //修改密码确认按钮
    function zxgmm() {
        if (zymmbln & zxmmbln1 & zxmmbln2) {  //验证都成功时
            var zymm = $("#zymm").val().trim();
            var zxpwd1 = $("#zxpwd1").val().trim();
            var zxpwd2 = $("#zxpwd2").val().trim();
            if (zxpwd1 != zxpwd2) {
                layer.msg('新密码和确认密码不一致', {
                    icon: 5
                });
            } else if (zymm == zxpwd1 | zymm == zxpwd2) {
                layer.msg('原密码和新密码一致', {
                    icon: 5
                });
            } else if (zxpwd1 == xpwd2 | zymm != xpwd1) {
                //验证原密码是否正确
                let zzz = layer.load();
                $.ajax({
                    url: '[[@{/setUser/selthi}]]',
                    type: 'post',
                    async: true,
                    data: {pwd: zymm},
                    dataType: 'json',
                    success: function (data) {
                        if (data == 0) {
                            layer.close(zzz);
                            layer.msg('原密码错误', {
                                icon: 5
                            });
                        } else if (data == 1) {  //验证成功后修改密码
                            $.ajax({
                                url: '[[@{/setUser/updthi}]]',
                                type: 'post',
                                async: true,
                                data: {xmm: zxpwd1},
                                dataType: 'json',
                                success: function (data2) {
                                    layer.close(zzz);
                                    if (data2 == 0) {
                                        layer.msg('系统错误，请联系管理员！', {icon: 3}, function () {
                                            location.reload();
                                        });
                                    } else if (data2 == 1) {
                                        layer.msg('修改成功！新支付密码打死也不要告诉别人！', {time: 1000, icon: 1}, function () {
                                            //刷新页面
                                            location.reload();
                                        });
                                    }
                                }
                            });
                        }
                    }
                });
            }
        } else {
            layer.msg('请完善信息！', {
                icon: 5
            });
        }
        if (!zymmbln) {
            $("#zymmts").css("display", "initial");
        }
        if (!zxmmbln1) {
            $("#zxmmts1").css("display", "initial");
        }
        if (!zxmmbln2) {
            $("#zxmmts2").css("display", "initial");
        }
        return false;
    }

</script>
</body>
</html>
